package com.gress.shop.vo;

import com.gress.shop.constants.PopConstants;

import java.io.Serializable;

/**
 * Created by xiongwen on 2017/12/6.
 */
public class SwalReturn<T> implements Serializable{

    private static final long serialVersionUID = 2136734426606185938L;
    private String type = PopConstants.SUCCESS;
    private String title = PopConstants.OP_SUCCESS;
    private String text ;
    private boolean success = true;

    private T data;



    public SwalReturn(String type, String title, String text) {
        this.type = type;
        this.title = title;
        this.text = text;
    }

    public SwalReturn() {
    }
    public SwalReturn(T t) {
        this.data = t;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getText() {
        return text;
    }

    public SwalReturn setText(String text) {
        this.text = text;
        return this;
    }

    public T getData() {
        return data;
    }


    public SwalReturn setData(T data) {
        this.data = data;
        return this;
    }

    public  boolean isSuccess(){
        if (PopConstants.SUCCESS.equals(this.type)) {
            return true;
        }
        return false;
    }

    /**
     * 设置状态,
     * <p>
     * true 成功
     * <p>
     * false 失败
     */
    public void setType(boolean type) {
        if (type) {
            this.type = PopConstants.SUCCESS;
        } else {
            this.type = PopConstants.ERROR;
        }
    }
}
